Ext.define('UmlWebEditor.tests.DiagrammFactoryTest', {
	extend: 'UmlWebEditor.tests.Test',
	requires: [
		'UmlWebEditor.factories.DiagrammFactory'
	],
	tests: {
		generateIdTest: function () {
			var factory = Ext.create('UmlWebEditor.factories.DiagrammFactory');
			var lastId = factory.getNextId();
			verify(factory.getNextId() > lastId++, "first id <= prev");
			verify(factory.getNextId() > lastId++, "second id <= prev");
			var error = false;
			try {
				var block = factory.createDiagramm('!!!', 12);
			} catch(e) {
				error = true;
			}
			verify(error, "createBlock - not catch error");
			verify(factory.getNextId() == ++lastId, "third id != lastId");
		},
		createCommonDiagrammTest: function () {
			var factory = Ext.create('UmlWebEditor.factories.DiagrammFactory');
			var error = false;
			try {
				var CommonDiagramm = factory.createDiagramm('CommonDiagramm', {
					id: 1234,
					flex: 10,
				});
			} catch(e) {
				error = true;
			}
			verify(!error, "CommonDiagramm - catch error");
			verify(CommonDiagramm.self.getName() == 'UmlWebEditor.view.CommonDiagramm', "CommonDiagramm not created, CommonDiagramm.self.getName()=" + CommonDiagramm.self.getName());
			verify(CommonDiagramm.getId() == 1234, "CommonDiagramm id != 1234, id="  + CommonDiagramm.getId());
			verify(CommonDiagramm.flex == 10, "CommonDiagramm flex != 10, id="  + CommonDiagramm.flex);

			verify(CommonDiagramm.getBlockKey() == -1, "CommonDiagramm blockKey != -1, key=" + CommonDiagramm.getBlockKey());
		},
		setDiagrammNameTest: function () {
			var factory = Ext.create('UmlWebEditor.factories.DiagrammFactory');
			var CommonDiagramm1 = factory.createDiagramm('CommonDiagramm', {
				key: 1235,
				flex: 10,
			});
			var CommonDiagramm2 = factory.createDiagramm('CommonDiagramm', {
				key: 1236,
				flex: 10,
			});
			verify(CommonDiagramm1.getName() == 'CommonDiagramm 1235', "CommonDiagramm1 has invalid name " + CommonDiagramm1.getName());
			verify(CommonDiagramm2.getName() == 'CommonDiagramm 1236', "CommonDiagramm2 has invalid name " + CommonDiagramm2.getName());
		}
	}
});
